package core;


import javax.swing.table.AbstractTableModel;

public class DynamicTableModel extends AbstractTableModel {

	private String[] columnNames;
	private Object[][] data;
	
	public DynamicTableModel(String[] columnInt, Object[][] data)
	{
		this.columnNames = columnInt;
		this.data = data;
	}
	
	
	@Override
	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public int getRowCount() {
		return data.length;
	}

	@Override
	public Object getValueAt(int row, int col) {
		return data[row][col];
	}
	
	public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
	
	public String getColumnName(int col) {
	        return columnNames[col];
	}
	
	public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }

}
